package br.com.fidalgotecnologia.layar.json;


import org.json.JSONException;
import org.json.JSONObject;

import br.com.fidalgotecnologia.core.constantes.Constante;
import br.com.fidalgotecnologia.core.constantes.Links;
import br.com.fidalgotecnologia.layar.entity.Object;



public class ObjectJson {
	private Object object;
    private JSONObject json;
    
    public ObjectJson(Object object){
    	this.object = object;
    	json = new JSONObject();
    	try {
    		if(this.object.getContentType().equalsIgnoreCase("imagem")){
    			json.put( "contentType",Constante.IMAGE_TYPE);
    		}else if(this.object.getContentType().equalsIgnoreCase("modelo")){
    			json.put( "contentType",Constante.MODEL_TYPE);
    		}
			json.put( "url", Links.LINK_OBJECT_FILE+this.object.getId());
			json.put( "reducedURL",Links.LINK_REDUCED_FILE+this.object.getId());
			
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    
   public JSONObject getJson() {
	return json;
}
    
	@Override
	public String toString() {
		String retorno = null;
		
		try {
			
			retorno = json.toString();
		} catch (Exception  e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return retorno;
	}

}